package com.fang.algorithm.sort.insert;

import java.util.Arrays;

/**
 * @author fanglingxiao
 * @version 1.0
 * @description 给你一个整数数组 nums，请你将该数组升序排列
 * 输入：nums = [5,1,1,2,0,0]
 * 输出：[0,0,1,1,2,5]
 * @date 2022/1/6 8:01 下午
 **/
public class Test02_Example {
    public static void main(String[] args) {
        int[] arr = new int[]{5, 1, 1, 2, 0, 0};
        sortArray(arr);
        System.out.println(Arrays.toString(arr));
    }

    private static void sortArray(int[] nums) {
        for (int i = 1; i < nums.length; i++) {
            int j = i;
            while (j >= 1 && nums[j] < nums[j - 1]) {
                int temp = nums[j];
                nums[j] = nums[j - 1];
                nums[j - 1] = temp;
                j--;
            }
        }
    }
}
